/*
 * Author  : Pallab
 * Program : G
 *
 * 2012-05-05 16:30:50
 * I have not failed, I have just found 10000 ways that won't work.
 *
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;


#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

template<class T1>
inline void debug(T1 _x) {
    cout<<_x<<'\n';
}
template<class T1, class T2>
inline void debug(T1 _x,T2 _y) {
    cout<<_x<<' '<<_y<<'\n';
}
template<class T1, class T2, class T3>
inline void debug(T1 _x,T2 _y,T3 _z) {
    cout<<_x<<' '<<_y<<' '<<_z<<'\n';
}
template<class T1, class T2, class T3, class T4>
inline void debug(T1 _x,T2 _y,T3 _z,T4 _zz) {
    cout<<_x<<' '<<_y<<' '<<_z<<' '<<_zz<<'\n';
}
template< class T1>
inline void debug(T1 _array,int _size) {
    cout<<"[";
    for (int i=0;i<_size;++i) {
        cout<<' '<<_array[i];
    }
    puts(" ]");
}
inline bool CI(int &_x) {
    return scanf("%d",&_x)==1;
}
inline bool CI(int &_x, int &_y) {
    return CI(_x)&&CI(_y) ;
}
inline bool CI(int &_x, int &_y, int &_z) {
    return CI(_x)&&CI(_y)&&CI(_z) ;
}
inline bool CI(int &_x, int &_y, int &_z, int &_zz) {
    return CI(_x)&&CI(_y)&&CI(_z)&&CI(_zz) ;
}

map<string,int> dict;
map<string,int> vis;
inline void Read() {
    dict.clear();
    string ss;
    while (getline(cin,ss)) {
        if (ss=="--")break;
        dict[ss]=1;
    }
}
inline bool bfs(string s, string t) {
    if (LN(s)!=LN(t))return false;
    if (s==t)return true;


    queue<string> q;
    vis.clear();

    q.push(s);
    vis[s]=1;

    while (!q.empty()) {
        string f = q.front();
        q.pop();

        //try to change a charecter
        for (char ch='a';ch<='z';++ch) {
            fo(i,LN(f)) {
                if (f[i]!=ch) {
                    char tmp = f[i];
                    f[i]=ch;
                    if ( vis.count(f)<1 ) {
                        if ( dict.count(f) ) {
                            if (f==t)return true;
                            q.push(f);
                            vis[f]=1;
                        }
                    }
                    f[i]=tmp;
                }
            }
        }

    }
    return false;
}
inline void Proc() {
    string ss1,ss2;
    while (cin>>ss1>>ss2) {
        if ( bfs(ss1,ss2) )cout<<"Yes";
        else cout<<"No";

        line;
    }
}
int main() {
    Read();
    Proc();
    return 0;
}

